package br.edu.unibratec.viagemfacil;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class FraseAdapter extends ArrayAdapter<Frase> {

	public FraseAdapter(Context context, List<Frase> objects) {
		super(context, 0, 0, objects);
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder;

		Frase frase = getItem(position);

		if (convertView == null) {
			convertView = LayoutInflater.from(getContext()).inflate(
					R.layout.linha_frase, null);

			holder = new ViewHolder();
			holder.txtFraseOriginal = (TextView) convertView
					.findViewById(R.id.textViewCategoria);
			holder.txtFraseTraduzida = (TextView) convertView
					.findViewById(R.id.textViewFraseTraduzida);
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.txtFraseOriginal.setText(frase.fraseOriginal);
		holder.txtFraseTraduzida.setText(frase.fraseTraduzida);

		return convertView;
	}

	static class ViewHolder {
		TextView txtFraseOriginal;
		TextView txtFraseTraduzida;
	}
}
